package com.ys.filelib.filedialog;

import android.content.Context;
import android.view.View;

import com.ys.filelib.databinding.FilelibDialogTipProgressBinding;

public class TipProgressDialog extends MyDialog {
    private FilelibDialogTipProgressBinding mView;
    private OnCancelListener mCancelListener;

    public TipProgressDialog(Context context) {
        super(context);
        mView = FilelibDialogTipProgressBinding.inflate(getInflater());
    }

    @Override
    protected View getView() {
        initView();
        return mView.getRoot();
    }

    private void initView() {
        mView.tvCancel.setOnClickListener(v -> {
            dismiss();
            if (mCancelListener != null) {
                mCancelListener.onCancel();
            }
        });
    }

    public void setProgress(int progress) {
        this.mView.pbBar.setProgress(progress);
    }

    public void setTitle(String title) {
        this.mView.tvTitle.setText(title);
    }

    public void setContent(String content) {
        this.mView.tvContent.setText(content);
    }

    public void setCancelListener(OnCancelListener listener) {
        mCancelListener = listener;
    }

    public interface OnCancelListener {
        void onCancel();
    }
}
